package com.yueya.api.user;

import java.util.Map;

import com.jfinal.aop.Clear;
import com.jfinal.aop.Duang;
import com.jfinal.kit.JsonKit;
import com.yueya.common.action.ApiController;
import com.yueya.common.model.Resp;

import net.sf.json.JSONObject;

/**
 * 用户
 * 
 * @author yangfeng
 * 
 */
public class IUserController extends ApiController {

	public void index() {
	}

	// 登陆
	@Clear
	public void login() {
		JSONObject jo = this.getJson();
		Resp map = Duang.duang(IUserService.class).login(jo);
		renderJson(JsonKit.toJson(map));
	}

	// 设置密码
	public void setPwd() {
		JSONObject jo = this.getJson();
		renderJson(JsonKit.toJson(Duang.duang(IUserService.class).setPwd(jo, this.getUserId())));
	}

	// 获取用户
	public void getUserInfo() {
		JSONObject jo = this.getJson();
		Map<String, Object> map = Duang.duang(IUserService.class).getUser(jo);
		renderJson(JsonKit.toJson(map));
	}

	// 获取用户列表
	public void getUserList() {
		JSONObject jo = this.getJson();
		Map<String, Object> map = Duang.duang(IUserService.class).getUserList(jo);
		renderJson(JsonKit.toJson(map));
	}

	public void uploadAvatar() {
		JSONObject jo = this.getJson();
		renderJson(JsonKit.toJson(Duang.duang(IUserService.class).uploadAvatar(jo, this.getUserId())));
	}

	@Clear
	public void uploadFile() {
		JSONObject jo = this.getJson();
		renderJson(JsonKit.toJson(Duang.duang(IUserService.class).uploadFile(jo, this.getUserId())));
	}

}
